//
// Created by tang on 23-3-12.
//

#ifndef PIINFO_PI_CONFIG_SERVICE_HPP
#define PIINFO_PI_CONFIG_SERVICE_HPP

#include "service/cfg_service.hpp"

struct ConfigObject;

class pi_config_service final : public IConfigService {
public:
    pi_config_service(std::string cfg_file_path);
    ~pi_config_service();

    std::unique_ptr<IGroup> group(const char *key, const std::string &display) override;

    void open();

    void close(bool save);

    void render_config_ui() const;
private:
    void load();
    void save();

    std::string const cfg_file_;
    ConfigObject     *cfg_obj_;
};

#endif  // PIINFO_PI_CONFIG_SERVICE_HPP
